﻿<!--[if lte IE 8]><link rel="stylesheet" type="text/css" href="/iehacks.css" /><![endif]-->
<!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="/ie6hacks.css" /><![endif]-->
<script type="text/javascript" src="/uploadify/jquery.ocupload-1.1.2.js"></script>

<body bgcolor="#ffffff" onLoad="rcube_init_mail_ui()" >
<roundcube:include file="/includes/header.html" />

<style type='text/css'>
td.title1 {
	width: 250px;
	padding-right: 10px;
	text-align:right;
}

#compose-headers td.editfield
{
  padding-right: 8px;
  margin:0px;
  width: 94%;
}

</style>


<script type="text/javascript">
rcmail.add2attachment_list = function(name, att, upload_id)
  {
    var li = $('<li>').attr('id', name).html(att.html);
    var indicator;

    // replace indicator's li
    if (upload_id && (indicator = document.getElementById(upload_id))) {
      li.replaceAll(indicator);
    }
    else { // add new li
      li.appendTo('#rcmAttachmentList');
    }
	
	if (rcmail.env.attachments == null)
		rcmail.env.attachments = new Array();
	

    if (upload_id && rcmail.env.attachments[upload_id])
      delete rcmail.env.attachments[upload_id];

    rcmail.env.attachments[name] = att;
	
	

    return true;
  };
  
  rcmail.remove_attachment = function(name)
  {
    if (name && rcmail.env.attachments[name])
      rcmail.http_post('remove-attachment', '_file='+urlencode(name));

    return true;
  };
  
  rcmail.remove_from_attachment_list = function(name)
  {
	$('#divAttachmentList').show();
	
    if (rcmail.env.attachments[name])
      delete rcmail.env.attachments[name];

    var list = document.getElementsByTagName("li");

    for (i=0;i<list.length;i++) {
      if (list[i].id == name) {
		$('#'+list[i].id).empty();
		$('#'+list[i].id).remove();
	  }
	}

  };
  
  rcmail.upload_file = function(form)
  {
    if (!form)
      return false;
	var sFile = "";

    // get file input fields
    var send = false;
    for (var n=0; n<form.elements.length; n++)
      if (form.elements[n].type=='file' && form.elements[n].value) {
        send = true;
		sFile = form.elements[n].value;
        break;
      }

    // create hidden iframe and post upload form
    if (send) {
      var ts = new Date().getTime();
      var frame_name = 'rcmupload'+ts;

      // have to do it this way for IE
      // otherwise the form will be posted to a new window
      if (document.all) {
        var html = '<iframe name="'+frame_name+'" src="program/blank.gif" style="width:0;height:0;visibility:hidden;"></iframe>';
        document.body.insertAdjacentHTML('BeforeEnd',html);
      }
      else 
	  { // for standards-compilant browsers
        var frame = document.createElement('iframe');
        frame.name = frame_name;
        frame.style.border = 'none';
        frame.style.width = 0;
        frame.style.height = 0;
        frame.style.visibility = 'hidden';
        document.body.appendChild(frame);
      }

      // handle upload errors, parsing iframe content in onload
      $(frame_name).bind('load', {ts:ts}, function(e) {
        var d, content = '';
        try {
          if (this.contentDocument) {
            d = this.contentDocument;
          } else if (this.contentWindow) {
            d = this.contentWindow.document;
          }
          content = d.childNodes[0].innerHTML;
        } catch (e) {
			alert('aseegsd');
		}

        if (!content.match(/add2attachment/) && (!bw.opera || (rcmail.env.uploadframe && rcmail.env.uploadframe == e.data.ts))) {
          if (!content.match(/display_message/))
            rcmail.display_message(rcmail.get_label('fileuploaderror'), 'error');
          rcmail.remove_from_attachment_list(e.data.ts);
        }
        // Opera hack: handle double onload
        if (bw.opera)
          rcmail.env.uploadframe = e.data.ts;
      });

      form.target = frame_name;
      form.action = rcmail.env.comm_path+'&_action=upload&_uploadid='+ts;
      form.setAttribute('enctype', 'multipart/form-data');
	  //$("div#attachment-form").find("#btnSubmit").click();
	  //$("div#attachment-form").find("form").submit();
	  $('form[name$="uploadform"]').submit();
      //document.forms['uploadform'].submit();

      // display upload indicator and cancel button
      var content = rcmail.get_label('uploading');
      //if (rcmail.env.loadingicon)
        content = '<img src="/images/display/loading_blue.gif" alt="" />'+content;
      //if (rcmail.env.cancelicon)
        content = '<a title="'+rcmail.get_label('cancel')+'" onclick="return rcmail.cancel_attachment_upload(\''+ts+'\', \''+frame_name+'\');" href="#cancelupload"><img src="/images/icons/delete.png" alt="" /></a>'+content;
      rcmail.add2attachment_list(ts, { name:'', html:content, complete:false });
    }


	// Remove this. If not, this form will be hidden after submit. So button click will not work in Chrome
    // rcmail.gui_objects.attachmentform = form;
    return true;
  };
  
  function onOCSubmit() {
	  var ts = new Date().getTime();
	  this.set('action', rcmail.env.comm_path+'&_action=upload&_uploadid='+ts);
	  
	  var content = rcmail.get_label('uploading');
      content = '<img src="/images/display/loading_blue.gif" alt="" />'+content;
      rcmail.add2attachment_list(ts, { name:'', html:content, complete:false });
  }

</script>


<form name="form" action="./" method="post">


<div id="module_content" style="margin-top:15px;"><!-- labels menu -->

<table border="0" cellpadding="0" cellspacing="0" width="100%" >
	<tbody>
	<tr>
		<td width="0"><br>
</td>
		<td style="padding-top: 3px;" valign="top" width="156" align="center">
				<span id="activefolders">
				
                <!-- 2 dòng Thư/Danh sách liên hệ -->
                <table style="width: 148; margin-left: 0px;" id="mail_menu1" class="m" border="0" cellpadding="0" cellspacing="0" width="160">
				<tbody>

                <!-- Thư -->
                <tr>
				<td style="width: 148px; padding-left: 15px;height:20px;  background-color: #DDE5FF;">
                <a class="button-mail" style="cursor:pointer" id="rcmbtn101" onClick="return rcmail.command(&#39;mail&#39;,&#39;&#39;,this)">
                <strong>Thư</strong></a>
                </td>
                </tr>

                <tr>
                <td style="height: 20px; width: 148px;" onMouseOver="style.backgroundColor='#EEF2FF';"
onmouseout="style.backgroundColor='#FFFFFF'">
                <span style="width: 148px; padding-left: 15px;">
                <a class="button-addressbook" style="cursor:pointer" id="rcmbtn102" onClick="return rcmail.command(&#39;addressbook&#39;,&#39;&#39;,this)">Danh sách liên hệ</a>
                </span></td>
				</tr>
			
                </tbody>
                </table>
								
				<!-- Left menu: mail box list -->
				<table style="width: 160px; overflow: hidden" id="mail_menu2" class="tbl_mail_menu" border="0" cellpadding="0" cellspacing="0" width="160">
				<tbody>
                <tr>
                <td style="height: 5px; background-image: url(skins/default/images/separator_line.png);background-repeat:no-repeat;">&nbsp;</td>
                </tr>
				<tr>
				<td style="width: 160px;" id="mcompose">

				<a style="margin-left: 20px" onClick="return rcmail.command('compose')" class="button cmd">Soạn thư</a>
  				</td>
				</tr>
				
				
				<tr><td style="width: 160px;overflow:hidden" class="label_inbox" id="minbox">
				<!-- Mail box list -->
				<div style="width: 160px;overflow:hidden; margin-top:10px;">
				<roundcube:object name="mailboxlist" id="mailboxlist" maxlength="25">
				</roundcube:object></div>
</td>
				</tr>
				
				</tbody>
				</table>
				
				
				
				<table id="mail_menu" class="m" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody><tr>
					<td>
						&nbsp;&nbsp;&nbsp;<br>
</td>
				</tr>
				</tbody></table>
				</span>


		</td>
		<td valign="top" style="background:#BBCCFF">
			<!-- right -->
			
			<span id="module_main_content">					 
					
<table bgcolor="#BBCCFF" border="0" cellpadding="0" cellspacing="0" width="100%">
	<tbody>
	<tr style="padding-right: 0px;">
		<td class="colt_ss"><br>
</td>
		<td class="colt_sus"><br>
</td>
	</tr>
	<tr bgcolor="#BBCCFF">
		<td width="4"><br>
</td>
		<td bgcolor="#edf0f9">

		<table bgcolor="#BBCCFF" border="0" cellpadding="4" cellspacing="0" width="100%">
			<tbody>
			<tr bgcolor="#BBCCFF" style="margin-top:10px;margin-left:5px;">
				<td valign="middle" >
                <div id="mailcontrol2" style="margin-left:10px">
						
                    <a onClick="return rcmail.command('send')" class="button cmd fontbold">Gửi</a>
                    <a onClick="return rcmail.command('savedraft')" class="button cmd">Lưu bây giờ</a>
                    <a onClick="return rcmail.command('list')" class="button cmd">Hủy</a>
				
			    </div>
					
					</td>


				<td align="right" valign="top" style="width: 70px;align:right;">&nbsp;

				</td>
			</tr>
		</tbody>
		</table>
		
		<!-- This is mail compose start-->
		<table border="0" cellspacing="0" cellpadding="1" id="compose-headers" height="400">
        <tr bgcolor="#BBCCFF" style="width:100%">
            <td height="34" class="title1"><label for="_from"><roundcube:label name="from" /></label></td>
            <td class="editfield formlinks">
                <roundcube:object name="composeHeaders" part="from" form="form" id="_from" tabindex="1" />
            </td>
        </tr>
        
        
        
        
        
        <tr bgcolor="#BBCCFF">
            <td height="34" class="title1 top"><label for="_to"><roundcube:label name="to" /></label></td>
            <td class="editfield"><roundcube:object name="composeHeaders" part="to" form="form" id="_to" cols="40" rows="2" tabindex="2" /></td>
        </tr>
        <tr id="compose-cc"  bgcolor="#BBCCFF">
            <td height="34" class="title1 top">
                <a href="#cc" onClick="return rcmail_ui.hide_header_form('cc');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
                <label for="_cc"><roundcube:label name="cc" /></label>
            </td>
            <td class="editfield"><roundcube:object name="composeHeaders" part="cc" form="form" id="_cc" cols="40" rows="2" tabindex="3" /></td>
        </tr>
        <tr id="compose-bcc"  bgcolor="#BBCCFF">
            <td height="34" class="title1 top">
                <a href="#bcc" onClick="return rcmail_ui.hide_header_form('bcc');"><img src="/images/icons/minus.gif" alt="" title="<roundcube:label name='delete' />" /></a>
                <label for="_bcc"><roundcube:label name="bcc" /></label>
            </td>
            <td colspan="2" class="editfield"><roundcube:object name="composeHeaders" part="bcc" form="form" id="_bcc" cols="40" rows="2" tabindex="4" /></td>
        </tr>


        <tr bgcolor="#BBCCFF">
            <td bgcolor="#BBCCFF"></td>
            <td class="formlinks">
                <a href="#cc" onClick="return rcmail_ui.show_header_form('cc')" id="cc-link"><roundcube:label name="addcc" /></a>
                <span class="separator">|</span>
                <a href="#bcc" onClick="return rcmail_ui.show_header_form('bcc')" id="bcc-link"><roundcube:label name="addbcc" /></a>
                
            </td>
        </tr>
        
        <tr  bgcolor="#BBCCFF">
            <td height="34" class="title1"><label for="compose-subject"><roundcube:label name="subject" /></label></td>
            <td class="editfield"><roundcube:object name="composeSubject" id="compose-subject" form="form" tabindex="8" /></td>
        </tr>
        
       <!-- Attachment list-->
        <tr valign="top" bgcolor="#BBCCFF">
            <td class="title1" rowspan="2"><img src="/images/icons/attachment.png" style="margin:0 0px; width: 16px; height: 16px;"/></td>
            <td class="editfield">
				<roundcube:object name="composeAttachmentList" 
					deleteIcon="/images/icons/delete.png" 
					cancelIcon="/images/icons/delete.png" 
					loadingIcon="/images/display/loading_blue.gif" 
					/>
            </td>
        </tr>
        <tr valign="top" bgcolor="#BBCCFF">
        <td class="editfield">
               <!-- <a class="attach_title cmd" id="addAttach" onClick="addAttach()">Thêm file đính kèm</a> -->
               
               <div id="file_upload" style="width:200px;height:20px;" ><a style="cursor:pointer;" class="attach_title cmd">Thêm file đính kèm</a></div>
<script type="text/javascript">
 	var myUpload = $('#file_upload').upload({
        name: '_attachments[]',
        action: './?_task=mail&_action=upload&_uploadid=35345646',
        enctype: 'multipart/form-data',
        params: {},
        autoSubmit: true,
        onSubmit: onOCSubmit,
        onComplete: function() {},
        onSelect: function() {}
});
</script>
        </td>
        </tr>
        
        
        <tr  bgcolor="#BBCCFF" >
            <td colspan="2" height="300px" class="editfield">
               <div style="position: relative; margin-left:5px; margin-right:0px;">
                    	<roundcube:object name="composeBody" id="compose-body" form="form" cols="70" rows="30" tabindex="9" 
                        style="width: 100%; height: 300px;margin-top:0px;"/>
              </div>
            </td>
              
        </tr>
        
        </table>

		<!-- This is mail compose end  -->
		
        <table bgcolor="#BBCCFF" border="0" cellpadding="4" cellspacing="2" width="100%">
			<tbody>
			
            <tr bgcolor="#BBCCFF">
				<td valign="middle" >
				  <div id="mailcontrol2" style="margin-left:10px">
				    
				    <a onClick="return rcmail.command('send')" class="button cmd fontbold">Gửi</a>
				    <a onClick="return rcmail.command('savedraft')" class="button cmd">Lưu bây giờ</a>
				    <a onClick="return rcmail.command('list')" class="button cmd">Hủy</a>
				    
				    </div>
				  
				  </td>

				<td align="right" valign="top" style="width: 70px;align:right;">&nbsp;
				  
				  </td>
			</tr>
            
		</tbody>
		</table>
		</td>
	</tr>
	
</tbody></table>
</span>
			<br>
			<roundcube:include file="/includes/footer.html" />
		</td>

</tr></tbody></table></div>

</form>

<roundcube:object name="composeAttachmentForm" id="attachment-form" attachmentFieldSize="40" 
style="position:absolute;;width:1px;height:1px;overflow:hidden; "/>

</body>